from bs4 import BeautifulSoup


class HtmlParserUtil:

    # 封装解析html的方法
    @classmethod
    def html_parser(cls, resp):
        bs = BeautifulSoup(resp.json().get("description").get("form"), "html.parser")
        # 获取请求的URL
        url = bs.form.get("action")
        # 定义字典 来存储请求参数名：参数值
        param = {}
        input_list = bs.find_all("input")
        # 遍历input_list列表
        for input in input_list:
            param[input.get("name")] = input.get("value")
        # 把URL 和参数返回
        return url, param


